package com.woniuxy.book.util;

import org.springframework.cglib.beans.BeanMap;

import java.util.Map;

public class BeanMapUtils {

    /**
     * 将map集合中的数据转化为指定对象的同名属性中
     */
    public static <T> T mapToBean(Map<Object, Object> map, Class<T> clazz) throws Exception {
        T bean = clazz.newInstance();
        BeanMap beanMap = BeanMap.create(bean);
        beanMap.putAll(map);
        return bean;
    }
}
